<h1>
	Rezerwacje sali
	<span class="breadcrumbs">
		&lt; <a href="<?= $ro->gen('hall.read', array('id' => $t['hall']['id'])) ?>"><?= e($t['hall']['name']) ?></a>
		&lt; <a href="<?= $ro->gen('reservation.halls') ?>">Wszystkie rezerwacje</a>
	</span>
</h1>

<div id="reservations">
	<form class="form" action="<?= $ro->gen('reservation.browse', array('hall' => $t['hall']['id'])) ?>">
		<fieldset class="fields">
			<ul class="horizontal">
				<li>
					<h2>Od <?= date('Y-m-d', $t['from']) ?> do <?= date('Y-m-d', $t['to']) ?></h2>
					<a id="prevWeek" href="<?= $ro->gen('reservation.browse', array('hall' => $t['hall']['id'], 'year' => $t['year'], 'week' => $t['week'] - 1)) ?>" title="Poprzedni tydzień">&lt;&lt;</a><input name="day" type="text" value="<?= $tm->_d($t['day'], 'medium_date') ?>" title="Dzień w formacie YYYY-MM-DD" /><a id="nextWeek" href="<?= $ro->gen('reservation.browse', array('hall' => $t['hall']['id'], 'year' => $t['year'], 'week' => $t['week'] + 1)) ?>" title="Następny tydzień">&gt;&gt;</a>
				</li>
				<li>&nbsp;</li>
				<li id="legend">
					<h2>Legenda statusów rezerwacji</h2>
					<span class="status-new">Nowe</span>
					<span class="status-accepted">Zaakceptowane</span>
					<span class="status-rejected">Odrzucone</span>
					<span class="status-closed">Zamknięte</span>
				</li>
			</ul>
		</fieldset>
	</form>
	<? if (empty($t['reservations'])): ?>
	<p>Brak rezerwacji dla tej sali w wybranym tygodniu.</p>
	<? endif ?>
	<? foreach ($t['reservations'] as $day => $reservations): ?>
	<h3><?= $tm->_d($day) ?></h3>
	<div class="reservation">
		<? if (!empty($reservations)): ?>
		<table>
			<tr>
				<th>Godziny</th>
				<? foreach ($reservations as $reservation): ?>
				<td class="status-<?= $reservation['status'] ?>"><?= $reservation['from'] ?>-<?= $reservation['to'] ?></td>
				<? endforeach ?>
			</tr>
			<tr>
				<th>Czas</th>
				<? foreach ($reservations as $reservation): ?>
				<td class="<?= $reservation['status'] ?>"><?= $reservation['time'] ?> min</td>
				<? endforeach ?>
			</tr>
			<tr>
				<th>Przez</th>
				<? foreach ($reservations as $reservation): ?>
				<td class="<?= $reservation['status'] ?>"><?= $reservation['creator'] ?></td>
				<? endforeach ?>
			</tr>
			<tr>
				<th>Akcje</th>
				<? foreach ($reservations as $reservation): ?>
				<td class="<?= $reservation['status'] ?>">
					<? foreach ($reservation['actions'] as $action): ?>
					<a class="<?= $action['type'] ?>" href="<?= $ro->gen($action['route'], array('hall' => $t['hall']['id'], 'id' => $reservation['id'])) ?>"><img src="<?= AgaviConfig::get('app.path') ?>/img/reservation_<?= $action['type'] ?>.png" alt="<?= $action['label'] ?>" title="<?= $action['label'] ?>" /></a>
					<? endforeach ?>
				</td>
				<? endforeach ?>
			</tr>
		</table>
		<? endif ?>
	</div>
	<a href="<?= $ro->gen($t['reserveRoute'], array('hall' => $t['hall']['id'], 'date' => $tm->_d($day, 'medium_date'))) ?>">Zarezerwuj salę w tym dniu</a>
	<? endforeach ?>
</div>

<script type="text/javascript">
$(function()
{
  $('#gallery img').click(function()
  {
    openZoom(this);
  });

	var fadeTime = 500;

	$('#legend span').each(function(_, el)
	{
		$(el).css('cursor', 'pointer').click(function()
		{
			var cls = $(this).toggleClass('off').attr('class').split(' ')[0];

			var headers = $('#reservations .reservation td.' + cls).toggle();
			var data    = $('#reservations .reservation td.' + cls.substr(7)).toggle();
		});
	});

	$('#legend span.status-rejected').click();
});
</script>